import request from '@/utils/request'
import { Teacher, TeacherQuery } from './type'
const baseUrl = '/teacher'

//分页
export const reqTeacherPage = (
  pageNum: number,
  pageSize: number,
  queryParams: TeacherQuery,
) =>
  request.post<any, TableResponse<Array<Teacher>>>(`${baseUrl}/page`, {
    pageNum,
    pageSize,
    ...queryParams,
  })

//修改用户状态
export const reqChangeStatus = (teacherId: string, status: string) =>
  request.get<any, ResponseData>(`${baseUrl}/changeStatus`, {
    params: {
      teacherId,
      status,
    },
  })

//删除用户
export const reqDeleteTeacher = (ids: string[] | string) =>
  request.delete<any, ResponseData>(`${baseUrl}/${ids}`)

//重置密码
export const reqResetTeacherPwd = (teacherId: string, password: string) =>
  request.put<any, ResponseData>(`${baseUrl}/resetPassword`, {
    teacherId,
    password,
  })

//新增/修改教师
export const reqAddTeacher = (data: Teacher) =>
  request.post<any, ResponseData>(baseUrl, data)

export const reqUpdateTeacher = (data: Teacher) =>
  request.put<any, ResponseData>(baseUrl, data)

export const reqTeacherList = () =>
  request.get<any, ResponseData>(`${baseUrl}/all`)
